namespace ESupervision.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class MessageModels : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.MessageRecipient",
                c => new
                    {
                        MessageRecipientID = c.Int(nullable: false, identity: true),
                        MessageID = c.Int(nullable: false),
                        ReceiverUserID = c.String(nullable: false, maxLength: 128),
                        MessageStatus = c.Int(nullable: false),
                        ReceivedTime = c.DateTime(nullable: false),
                    })
                .PrimaryKey(t => t.MessageRecipientID)
                .ForeignKey("dbo.Message", t => t.MessageID, cascadeDelete: true)
                .ForeignKey("dbo.AspNetUsers", t => t.ReceiverUserID, cascadeDelete: true)
                .Index(t => t.MessageID)
                .Index(t => t.ReceiverUserID);
            
            CreateTable(
                "dbo.Message",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        SentByUserId = c.String(nullable: false, maxLength: 128),
                        Subject = c.String(nullable: false, maxLength: 1000),
                        Body = c.String(nullable: false, maxLength: 4000),
                        SentTime = c.DateTime(nullable: false),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.AspNetUsers", t => t.SentByUserId, cascadeDelete: false)
                .Index(t => t.SentByUserId);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.MessageRecipient", "ReceiverUserID", "dbo.AspNetUsers");
            DropForeignKey("dbo.Message", "SentByUserId", "dbo.AspNetUsers");
            DropForeignKey("dbo.MessageRecipient", "MessageID", "dbo.Message");
            DropIndex("dbo.MessageRecipient", new[] { "ReceiverUserID" });
            DropIndex("dbo.Message", new[] { "SentByUserId" });
            DropIndex("dbo.MessageRecipient", new[] { "MessageID" });
            DropTable("dbo.Message");
            DropTable("dbo.MessageRecipient");
        }
    }
}
